#ifndef __GAMEACTION_H__
#define __GAMEACTION_H__

#include <vector>
#include <string>
#define MEDIAPATH "/APPS/missilecmd/media/"

using std::vector;
using std::string;

class MissileInfo
{
public:
  int xs, ys;
  int xf, yf;
  int x,  y;
  bool split;
  int splitcount;
  int splittime;
  MissileInfo *splitmissiles;
  enum {PLAYER,ENEMY} owner;
};

class GameAction
{
public:
  /**
   * Do whatever action.
   * Return true to move to the next action,
   * return false if we should come back to this
   * action again.
   */
  virtual bool perform() = 0;
};

class GameActionList : public GameAction
{
public:
  ~GameActionList();
  void begin();

  bool perform();

  void add(GameAction *action);

protected:
  void relJump(int jump);

  vector<GameAction*> actions;
  vector<GameAction*>::iterator current;
  
  friend class LoopAction;
};

class ShowTextAction : public GameAction
{
public:
  ShowTextAction(const char *str, f32 x, f32 y);
  bool perform();
};

class FadeOutTextAction : public GameAction
{
public:
  bool perform();
};

class HideTextAction : public GameAction
{
public:
  bool perform();
};

class SetFadeAction : public GameAction
{
public:
  SetFadeAction(f32 fadeLevel);
  bool perform();
protected:
  f32 fadeLevel;
};

class FadeToAction : public GameAction
{
public:
  FadeToAction(f32 fadeLevel);
  bool perform();
protected:
  f32 fadeLevel;
};

class LoopActionCondition {
};

class LoopAction : public GameAction
{
public:
  LoopAction(int looptarget, LoopActionCondition *loopcondition);
  bool perform();
protected:
  int loopTarget;
  LoopActionCondition *loopCondition;
};

class DelayAction : public GameAction
{
public:
  DelayAction(int delayFrames);
  bool perform();
protected:
  int delayFrames;
  int frameCount;
};

class WaitButtonPressAction : public GameAction
{
public:
  WaitButtonPressAction(u32 buttonMask);
  bool perform();
protected:
  u32 buttonMask;
};

class PauseAction : public GameAction
{
public:
  bool perform();
};

class ResumeAction : public GameAction
{
public:
  bool perform();
};

class DisableGameInputAction : public GameAction
{
public:
  bool perform();
};

class EnableGameInputAction : public GameAction
{
public:
  bool perform();
};

class AbortAction : public GameAction
{
public:
  bool perform();
};

class AddMissileAction : public GameAction
{
public:
  AddMissileAction(MissileInfo *minfo);
  bool perform();
};

class GameTrigger;

class RegisterTriggerAction : public GameAction
{
public:
  RegisterTriggerAction(GameTrigger *trigger);
  ~RegisterTriggerAction();
  bool perform();
protected:
  GameTrigger *trigger;
};

class LoadActionListAction : public GameAction
{
public:
  LoadActionListAction(GameActionList *actionlist);
  bool perform();
protected:
  GameActionList *actionlist;
};

class ReInitializeAction : public GameAction
{
public:
  bool perform();
};

#endif
